import random

setGlobalDuration(30)

# mono to quad
setChannels(1)
pitchs = [random.randint(50,100) for i in range(10)]
waveform(pitch=pitchs, amplitude=.1, out='syn')
lfo(bus='pan', amplitude=.5, frequency=.5)
pan1to4(input='syn', panVar='pan')

# stereo to quad
setChannels(2)
playSound(pitch=.95, amplitude=.5, loop=True, out='snd1')
playSound(pitch=1.05, amplitude=.5, loop=True, out='snd2')
pan2to4(input='snd1', pan=0)
pan2to4(input='snd2', pan=.5)

# panning mono to quad with dynamic spread
lfo(bus='pan2', amplitude=.5, offset=.5, frequency=.2)
lfo(bus='spread2', amplitude=.5, offset=.5, frequency=.35)
playSound(pitch=4, amplitude=.3, loop=True, out='snd3')
panner(input='snd3', numinputs=1, numoutputs=4, panVar='pan2', spreadVar='spread2')

# write a file to disk
startCsound(file='outQuad', channels=4)
